package com.qfjy.homework.liuya;

/**
 * @version 1.0
 * @outhor ly
 * @date2023/6/29 17:35
 */

/**
 * 使用该工厂，通过传递类型信息来获取实体类的对象
 */
public class FactoryPatternDemo {
    public static void main(String[] args) {
        ShapeFactory shapeFactory = new ShapeFactory();
        //获取circle对象并调用draw方法
        Shape shape1 = shapeFactory.getShape("CIRCLE");
        //调用circle的draw方法
        shape1.draw();
        //获取 Rectangle 的对象，并调用它的 draw 方法
        Shape shape2 = shapeFactory.getShape("RECTANGLE");
        shape2.draw();
        //获取 Square 的对象，并调用它的 draw 方法
        Shape shape3 = shapeFactory.getShape("SQUARE");
        shape3.draw();

    }
}
